<?php
declare(strict_types=1);
namespace Field;

class SysUserConst
{
    public const pk='UserID';
    public const index=['UserID'];
	public const fields=['UserID','ParentUserID','UnID','RoleID','AvatarAt','Mobile','UserName','NickName','Balance','Bonus','Points','PassWord','Salt','CreateIP','CreateYmd','CreateAt','UpdateAt','LoginNum','Status','UserLevelID','ShopID'];
	public const comment=['UserID'=>'会员ID','ParentUserID'=>'推荐用户ID','UnID'=>'用来对外显示','RoleID'=>'权限ID','AvatarAt'=>'','Mobile'=>'手机号','UserName'=>'账户','NickName'=>'昵称','Balance'=>'余额','Bonus'=>'佣金','Points'=>'积分','PassWord'=>'密码','Salt'=>'盐','CreateIP'=>'注册IP','CreateYmd'=>'创建年月日方便统计','CreateAt'=>'创建时间','UpdateAt'=>'更新时间','LoginNum'=>'登陆次数','Status'=>'状态','UserLevelID'=>'代理等级','ShopID'=>'淘宝店铺ID'];
	/*
    * @Field UserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 会员ID
    */
    public const UserID = 'UserID';
    /*
    * @Field ParentUserID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 推荐用户ID
    */
    public const ParentUserID = 'ParentUserID';
    /*
    * @Field UnID
    * @Type bigint(20)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 用来对外显示
    */
    public const UnID = 'UnID';
    /*
    * @Field RoleID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 权限ID
    */
    public const RoleID = 'RoleID';
    /*
    * @Field AvatarAt
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const AvatarAt = 'AvatarAt';
    /*
    * @Field Mobile
    * @Type varchar(16)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 手机号
    */
    public const Mobile = 'Mobile';
    /*
    * @Field UserName
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key UNI
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 账户
    */
    public const UserName = 'UserName';
    /*
    * @Field NickName
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 昵称
    */
    public const NickName = 'NickName';
    /*
    * @Field Balance
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 余额
    */
    public const Balance = 'Balance';
    /*
    * @Field Bonus
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 佣金
    */
    public const Bonus = 'Bonus';
    /*
    * @Field Points
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 积分
    */
    public const Points = 'Points';
    /*
    * @Field PassWord
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 密码
    */
    public const PassWord = 'PassWord';
    /*
    * @Field Salt
    * @Type varchar(8)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 盐
    */
    public const Salt = 'Salt';
    /*
    * @Field CreateIP
    * @Type varchar(20)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 注册IP
    */
    public const CreateIP = 'CreateIP';
    /*
    * @Field CreateYmd
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 创建年月日方便统计
    */
    public const CreateYmd = 'CreateYmd';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 创建时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 更新时间
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field LoginNum
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 登陆次数
    */
    public const LoginNum = 'LoginNum';
    /*
    * @Field Status
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 状态
    */
    public const Status = 'Status';
    /*
    * @Field UserLevelID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 1
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 代理等级
    */
    public const UserLevelID = 'UserLevelID';
    /*
    * @Field ShopID
    * @Type bigint(20)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 淘宝店铺ID
    */
    public const ShopID = 'ShopID';
}

class SysUserColumns
{
public  int $UserID;
   public  int $ParentUserID=0;
   public  int $UnID=0;
   public  int $RoleID=0;
   public  int $AvatarAt=0;
   public  ?string $Mobile='';
   public  ?string $UserName='';
   public  ?string $NickName='';
   public  int $Balance=0;
   public  int $Bonus=0;
   public  int $Points=0;
   public  ?string $PassWord='';
   public  ?string $Salt='';
   public  ?string $CreateIP='';
   public  int $CreateYmd=0;
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
   public  int $LoginNum=0;
   public  int $Status=0;
   public  int $UserLevelID=0;
   public  int $ShopID=0;
	public function toArray():array
	{
		return [
'UserID'=>$this->UserID,
    'ParentUserID'=>$this->ParentUserID,
    'UnID'=>$this->UnID,
    'RoleID'=>$this->RoleID,
    'AvatarAt'=>$this->AvatarAt,
    'Mobile'=>$this->Mobile,
    'UserName'=>$this->UserName,
    'NickName'=>$this->NickName,
    'Balance'=>$this->Balance,
    'Bonus'=>$this->Bonus,
    'Points'=>$this->Points,
    'PassWord'=>$this->PassWord,
    'Salt'=>$this->Salt,
    'CreateIP'=>$this->CreateIP,
    'CreateYmd'=>$this->CreateYmd,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,
    'LoginNum'=>$this->LoginNum,
    'Status'=>$this->Status,
    'UserLevelID'=>$this->UserLevelID,
    'ShopID'=>$this->ShopID,        ];
	}
}

class SysUserRow
{
	public SysUserColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'UserID' => $this->data->UserID,
        'ParentUserID' => $this->data->ParentUserID,
        'UnID' => $this->data->UnID,
        'RoleID' => $this->data->RoleID,
        'AvatarAt' => $this->data->AvatarAt,
        'Mobile' => $this->data->Mobile,
        'UserName' => $this->data->UserName,
        'NickName' => $this->data->NickName,
        'Balance' => $this->data->Balance,
        'Bonus' => $this->data->Bonus,
        'Points' => $this->data->Points,
        'PassWord' => $this->data->PassWord,
        'Salt' => $this->data->Salt,
        'CreateIP' => $this->data->CreateIP,
        'CreateYmd' => $this->data->CreateYmd,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt,
        'LoginNum' => $this->data->LoginNum,
        'Status' => $this->data->Status,
        'UserLevelID' => $this->data->UserLevelID,
        'ShopID' => $this->data->ShopID, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysUserColumns();
        isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['ParentUserID']) && $this->data->ParentUserID = (int)$data['ParentUserID'];
           isset($data['UnID']) && $this->data->UnID = (int)$data['UnID'];
           isset($data['RoleID']) && $this->data->RoleID = (int)$data['RoleID'];
           isset($data['AvatarAt']) && $this->data->AvatarAt = (int)$data['AvatarAt'];
           isset($data['Mobile']) && $this->data->Mobile = (string)$data['Mobile'];
           isset($data['UserName']) && $this->data->UserName = (string)$data['UserName'];
           isset($data['NickName']) && $this->data->NickName = (string)$data['NickName'];
           isset($data['Balance']) && $this->data->Balance = (int)$data['Balance'];
           isset($data['Bonus']) && $this->data->Bonus = (int)$data['Bonus'];
           isset($data['Points']) && $this->data->Points = (int)$data['Points'];
           isset($data['PassWord']) && $this->data->PassWord = (string)$data['PassWord'];
           isset($data['Salt']) && $this->data->Salt = (string)$data['Salt'];
           isset($data['CreateIP']) && $this->data->CreateIP = (string)$data['CreateIP'];
           isset($data['CreateYmd']) && $this->data->CreateYmd = (int)$data['CreateYmd'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['LoginNum']) && $this->data->LoginNum = (int)$data['LoginNum'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
           isset($data['UserLevelID']) && $this->data->UserLevelID = (int)$data['UserLevelID'];
           isset($data['ShopID']) && $this->data->ShopID = (int)$data['ShopID'];
    }
}
?>